﻿@{
    ViewBag.Title = "支付详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="weui-cells weui-cells_form">
    <div class="weui-cell weui-cell_warn">
        <div class="weui-cell__hd">
            <label for="" class="weui-label">订单号：</label>
        </div>
        <div class="weui-cell__bd">
            @Model.OutTradeNo
        </div>
    </div>
    <div class="weui-cell  weui-cell_warn">
        <div class="weui-cell__hd">
            <label class="weui-label">金 额：</label>
        </div>
        <div class="weui-cell__bd">
            @Model.TotalFee/100 元
        </div>
        <div class="weui-cell__ft">
            <i class="weui-icon-success"></i>
        </div>
    </div>
</div>

<div class="weui-btn-area">
    <a class="weui-btn weui-btn_primary" href="javascript:callpay()" id="pay">确认支付</a>
</div>

@section scripts{
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script type="text/javascript">

        function pay() {
            onBridgeReady();
        }

        function onBridgeReady() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": '@ViewBag.AppId',     //公众号名称，由商户传入
                    "timeStamp": '@ViewBag.timestamp',         //时间戳，自1970年以来的秒数
                    "nonceStr": '@ViewBag.nonceStr', //随机串
                    "package": '@ViewBag.package',
                    "signType": '@ViewBag.signType',         //微信签名方式：
                    "paySign": '@ViewBag.paySign' //微信签名
                },
                function (res) {
                    if (res.err_msg === "get_brand_wcpay_request:ok") {
                        $.alert("支付成功！");
                        // 支付成功，后续自行处理
                        window.location.href = "/pay";
                    }
                    else {
                        alert("支付发生错误");
                        //支付取消，或者其他错误，自行处理
                    }
                }
            );
        }

    </script>
}
